startswith() returns True if a string starts with a specified substring.
def starts_with(s1, s2):
result = s2.startswith(s1)
return result
Function Call | Return Value | |||
---|---|---|---|---|
starts_with('H', 'Hello') | → | |||
starts_with('el', 'Hello') | → | |||
starts_with('Hel', 'Hello') | → | |||
starts_with('5', '525') | → | |||
starts_with('52', '525') | → | |||
starts_with('25', '525') | → | |||
starts_with('E', 'Egg') | → | |||
starts_with('', 'World') | → | |||
starts_with(' ', ' Hello World') | → | |||
starts_with(' ', 'HelloWorld') | → |
Experiment with this code on Gitpod.io